package com.wang.mapper;

import com.wang.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandMapper {

    //查询所有
    @Select("select * from tb_brand")
    @ResultMap("brandResultMap")
    List<Brand> SelectAll();

    //新增数据
    @Insert("insert into tb_brand values(null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);

    //修改数据
    @Update("update tb_brand set brand_name=#{brandName},company_name=#{companyName},ordered=#{ordered},description=#{description},status=#{status} where id=#{id}")
    void update(Brand brand);

    //删除数据
    @Delete("delete from tb_brand where id= #{id}")
    void delete(int id);

    //批量删除
    void deleteByIds(@Param("ids") int[] ids);

    //分页查询
    @Select("select * from tb_brand limit #{begin} ,#{size}")
    @ResultMap("brandResultMap")
    List<Brand> seleteByPage(@Param("begin") int begin,@Param("size") int size);

    //查询记录数
    @Select("select count(*) from tb_brand")
    int selectTotalCount();

    //分页搜索查询

    List<Brand> seleteByPageAndCondition(@Param("begin") int begin,@Param("size") int size,@Param("brand")Brand brand);

    //查询记录数

    int selectTotalCountAndCondition(Brand brand);
}
